package com.water.expert.extraction.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    public ResponseEntity<Map<String, String>> handleValidationException(RuntimeException ex) {
        Map<String, String> errors = new HashMap<>();
        
        errors.put("message", ex.getMessage());
        
        return ResponseEntity.badRequest().body(errors);
    }
}
